[#include "single/layout/layout02/layout.ftl"/]
[@htmlHead]
<link href="${jpath}/assets/public/plugins/jquery-ztree/3.5.12/css/zTreeStyle/zTreeStyle.min.css" rel="stylesheet"
      type="text/css"/>

[/@htmlHead]

[@htmlBody]

<div class="row" style="height: 400px;overflow: auto;">
    <div class="col-xs-12">
        <div id="ztree" class="ztree"></div>
    </div>
</div>
<div class="row navbar-fixed-bottom">
    <div class="col-xs-12 text-center">
        <input type="button" class="btn btn-sm btn-info btn-sm" value="确定" onclick="doSave()"/>
        <input type="button" class="btn btn-cancle  btn-sm" value="关闭" onclick=" top.$.bootbox.hideAll();"/>
    </div>
</div>
[/@htmlBody]

[@htmlFoot]
<script type="text/javascript"
        src="${jpath}/assets/public/plugins/jquery-ztree/3.5.12/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript">

    //ztree
    var setting = {

        callback: {
            onDblClick: function (event, treeId, treeNode) {
                doInfo(treeNode.id, treeNode.name)
            }
        },
        async: {
            dataType: 'jsonp',
            type: "get",
            enable: true,
            url: "${base}/area/view/treeList"
        }
    };

    function doInfo(id, name) {
        var idField = tools.getQueryString('idField');
        var textField = tools.getQueryString('textField');
        var fn = tools.getQueryString('fn');
        if (typeof fn == 'function') {
            eval("top." + fn + "(" + id + "," + name + ")");
        } else {
            var contentFrame = tools.getCurrentFrame();
            if (contentFrame) {
                var contentFrameDoc = contentFrame.document;
                $("#" + idField, contentFrameDoc).val(id);
                $("#" + textField, contentFrameDoc).val(name);
            }
            else {
                $("#" + idField, top.window.document).val(id);
                $("#" + textField, top.window.document).val(name);
            }

            top.$.bootbox.hideAll();
        }
    }

    function doSave() {
        var treeObj = $.fn.zTree.getZTreeObj("ztree");
        var nodes = treeObj.getSelectedNodes();//获得选中节点数据集合
        if (nodes.length > 0) {
            doInfo(nodes[0].id, nodes[0].name);
        }
        else {
            top.$.bootbox.hideAll();
        }
    }

    $(function () {
        $.fn.zTree.init($("#ztree"), setting, null);
    })
</script>
[/@htmlFoot]
